    //按指定位置删除
    Array.prototype.removeIndex = function (index) {
        if (index > -1) {
            this.splice(index, 1);
        }
    };
    //按元素名称删除
    Array.prototype.remove = function (val) {
        var index = this.indexOf(val);
        if (index > -1) {
            this.splice(index, 1);
        }
    };
    //添加元素到指定位置
    Array.prototype.add = function (val, index) {
        if (index > -1) {
            this.splice(index, 0, val);
        }
    };

    const commonObject = {
        //随机颜色，十六进制方法；方法一
        getRandomColor() {
            var rand = Math.floor(Math.random() * 0xFFFFFF).toString(16);
            if (rand.length == 6) {
                return '#' + rand;
            } else {
                return this.getRandomColor();
            }
        },
        //随机颜色，十六进制方法；方法二
        getRandomColors(value) {
            var color = '#'
            if (value && value.length > 0) {
                color = value
            }
            return (color += '0123456789abcdef' [Math.floor(Math.random() * 16)]) && (color.length == 7) ? color : this.getRandomColors(color);
        },

        /**
         * 生成从minNum到maxNum的随机数
         */
        randomNum(minNum, maxNum) {
            switch (arguments.length) {
                case 1:
                    return parseInt(Math.random() * minNum + 1, 10);
                    break;
                case 2:
                    return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
                    break;
                default:
                    return 0;
                    break;
            }
        },
        /**
         *  时间格式化
         */
        nowdDte: function (time) {
            var date = time || new Date();
            var year = date.getFullYear();
            /* 在日期格式中，月份是从0开始的，因此要加0
             * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
             * */
            var month =
                date.getMonth() + 1 < 10 ?
                "0" + (date.getMonth() + 1) :
                date.getMonth() + 1;
            var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var hours =
                date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
            var minutes =
                date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
            var seconds =
                date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
            // 拼接
            return (
                year +
                "-" +
                month +
                "-" +
                day +
                " " +
                hours +
                ":" +
                minutes +
                ":" +
                seconds
            );
        },

        /**
         *  将"2018-05-19T08:04:52.000+0000" -> 2018-5-19 08:00:00
         */
        myFunction(time) {
            // var dateee = new Date("2018-05-19T00:00:00.000+0000").toJSON();
            var dateee = new Date(time).toJSON();
            var date = new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
            return date
        },
        /**
         * 计算两个时间的差值找到离当前时间最近的时间
         */
        comparedate(obj1, obj2) {
            var getStampzhj = function(date) {
                date = date.substring(0,19);    
                date = date.replace(/-/g,'/'); 
                var timestamp = new Date(date).getTime();
                return timestamp
            }

            var val1 = getStampzhj(obj1.createdAt);
            var val2 = getStampzhj(obj2.createdAt);
            return val1 - val2;
        },
        

    }

    export default commonObject;